package api

import (
	"fmt"
	"git.supremind.info/product/box/vehicle/global"
	"git.supremind.info/product/box/vehicle/internal/dto"
	"git.supremind.info/product/box/vehicle/internal/util"
	"github.com/gin-gonic/gin"
	"net/http"
)

//若干network选项设置，接口会阻塞至配置生效或失败后返回
func NetworkOption(c *gin.Context) {
	var req = dto.NetworkSetting{}
	if c.BindJSON(&req) != nil {
		url := fmt.Sprintf("%s/v1/network/option", global.VmrSetting.Host)
		res, err := util.PostData(url, req)
		if err != nil {
			c.JSON(http.StatusOK, dto.Result{Code: -1, Message: err.Error()})
		} else {
			c.JSON(http.StatusOK, res)
		}
	} else {
		c.JSON(http.StatusOK, dto.Result{Code: -1, Message: "传参有误"})
	}
}

